var searchDAO = require('../models/searchDAO')
var searchController = {
    //模糊搜索
    searchContent: function (req, res) {
        var searchName = req.params.searchName
        // console.log(searchName)
        searchDAO.searchContent(searchName, function (err, results) {
            if (err) {
                res.json({ code: 500, msg: '查询失败' })
            } else {
                if (results.length > 0) {
                    res.json({ code: 200, data: results, msg: '用户信息查询成功!' })
                } else {
                    res.json({ code: 200, msg: '查询的东西不存在!' })
                }
            }
        })
    },
    // searchNum: function (req, res) {
    //     var searchName = req.params.searchName
    //     console.log(searchName)
    //     searchDAO.searchNum(searchName, function (err, results) {
    //         if (err) {
    //             res.json({ code: 500, msg: '查询失败' })
    //         } else {
    //             // res.json({code:200,data:results,msg:'查询成功!'})
    //             if (results.length > 0) {
    //                 res.json({ code: 200, data: results, msg: '用户信息查询成功!' })
    //             } else {
    //                 res.json({ code: 200, msg: '查询的东西不存在!' })
    //             }
    //         }
    //     })
    // }
}
module.exports = searchController